accessible: Add a way to hide accessibles
authorMatthias Clasen <mclasen@redhat.com>
Mon, 12 Oct 2020 20:22:52 +0000 (16:22 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 13 Oct 2020 01:43:17 +0000 (21:43 -0400)
Similar to gtk_widget_should_layout(), add a
gtk_accessible_should_present() function that backends can
use to determine whether an accessible should be presented
or not.

Ways to make a widget not presented in a11y:
- hide the widget
- set its role to NONE
- make it have a NULL AT context

We will use this in future to hide the GtkText inside
an entry, since the Text implementation will be done
by the wrapper.

gtk/gtkaccessible.c
gtk/gtkaccessibleprivate.h

index dd5890ca92b9349cb8a6f234a40e1e542e2144d6..49186ed0ffb080a011bcc0b6935c7b003f37dcdd 100644 (file)
@@ -47,6 +47,7 @@
 #include "gtkatcontextprivate.h"
 #include "gtkenums.h"
 #include "gtktypebuiltins.h"
+#include "gtkwidget.h"
 
 #include <glib/gi18n-lib.h>
 
@@ -649,3 +650,15 @@ gtk_accessible_platform_changed (GtkAccessible               *self,
   gtk_at_context_update (context);
 }
 
+gboolean
+gtk_accessible_should_present (GtkAccessible *self)
+{
+  if (GTK_IS_WIDGET (self) &&
+      !gtk_widget_get_visible (GTK_WIDGET (self)))
+    return FALSE;
+
+  if (gtk_accessible_get_accessible_role (self) == GTK_ACCESSIBLE_ROLE_NONE)
+    return FALSE;
+
+  return TRUE;
+}
index 092f9c2d9c156ce6ecdc184abc3008181a383391..ae4847f39c11410de75b6d1cf918f9a0760bfd0c 100644 (file)
@@ -40,4 +40,6 @@ const char *    gtk_accessible_role_to_name     (GtkAccessibleRole  role,
 void            gtk_accessible_platform_changed (GtkAccessible               *self,
                                                  GtkAccessiblePlatformChange  change);
 
+gboolean        gtk_accessible_should_present   (GtkAccessible     *self);
+
 G_END_DECLS